# Flask应用中用于注册URL路由的部分
"""视图函数路由模块"""
from air_web.web_flask.views.analysis_page import AnalysisPage
from air_web.web_flask.views.common_page import CommonPage
from air_web.web_flask.views.monitor_page import MonitorPage
from air_web.web_flask.views.notify_page import NotifyPage
from air_web.web_flask.views.predict_page import PredictPage
from air_web.web_flask.views.report_page import ReportPage
from air_web.web_flask.views.user_predict_page import UserPredictPage

# 接受app作为参数，并且在其上注册不同的URL路由
def register_urls(app):
    """统一注册路由到app"""
    # app.add_url_rule(URL路径，指定视图函数，支持的HTTP方法)
    # 筛选框
    # Get请求，获取组织信息，CommonPage
    app.add_url_rule(
        "/v1/common/org", view_func=CommonPage.org, methods=["GET"]
    )
    # Get请求，获取类型代码信息，CommonPage
    app.add_url_rule(
        "/v1/common/type_code", view_func=CommonPage.type_code, methods=["GET"]
    )
    # Get请求，进行条件搜索，CommonPage
    app.add_url_rule(
        "/v1/common/cons", view_func=CommonPage.cons_search, methods=["GET"]
    )
    # Get请求，获取完成时间信息，CommonPage
    app.add_url_rule(
        "/v1/common/finish_time", view_func=CommonPage.finish_time, methods=["GET"]
    )

    # 环比
    # Get请求，获取空气环比数据，AnalysisPage
    app.add_url_rule(
        "/v1/analysis/air_huan",
        view_func=AnalysisPage.air_huanbi,
        methods=["GET"],
    )
    # 同比
    # Get请求，获取空气同比数据，AnalysisPage
    app.add_url_rule(
        "/v1/analysis/air_tong",
        view_func=AnalysisPage.air_tongbi,
        methods=["GET"],
    )

    # 四川启动调控的地市
    # GET请求，获取四川启动调控的地市信息，MonitorPage
    app.add_url_rule(
        "/v1/monitor/alert_city",
        view_func=MonitorPage.alert_city,
        methods=["GET"],
    )
    # 四川测算基线曲线图
    # GET请求，获取四川测算基线曲线图数据，MonitorPage
    app.add_url_rule(
        "/v1/monitor/city_graph",
        view_func=MonitorPage.city_graph,
        methods=["GET"],
    )
    # 四川环比压降接口
    # GET请求，获取城市环比压降数据，ReportPage
    app.add_url_rule(
        "/v1/report/city_chain",
        view_func=ReportPage.city_chain,
        methods=["GET"],
    )

    # 天气
    # POST请求，上传天气数据，CommonPage
    app.add_url_rule(
        "/v1/special/upload_weather",
        view_func=CommonPage.upload_weather,
        methods=["POST"],
    )
    # GET请求，下载天气数据示例，CommonPage
    app.add_url_rule(
        "/v1/special/download_weather_demo",
        view_func=CommonPage.download_weather_demo,
        methods=["GET"],
    )

    # 产业行业预测 - 产业行业筛选框
    # GET请求，获取产业行业信息，CommonPage
    app.add_url_rule(
        "/v1/common/industry",
        view_func=CommonPage.industry_info,
        methods=["GET"],
    )
    # 产业行业预测
    # GET请求，获取产业行业预测数据,PredictPage
    app.add_url_rule(
        "/v1/predict/industry_predict",
        view_func=PredictPage.industry_predict,
        methods=["GET"],
    )
    # 用户预测
    # GET请求，获取用户预测数据,UserPredictPage
    app.add_url_rule(
        "/v1/user_air_predict",
        view_func=UserPredictPage.user_air_predict,
        methods=["GET"],
    )
    # GET请求，进行用户条件搜索,UserPredictPage
    app.add_url_rule(
        "/v1/user_cons",
        view_func=UserPredictPage.user_cons_search,
        methods=["GET"],
    )
    # 总负荷预测
    # GET请求，获取总负荷预测数据,PredictPage
    app.add_url_rule(
        "/v1/predict/fk_predict",
        view_func=PredictPage.fk_predict,
        methods=["GET"],
    )
    # 空调最大负荷预测
    # GET请求，获取空调最大负荷预测数据,PredictPage
    app.add_url_rule(
        "/v1/predict/max_p_predict",
        view_func=PredictPage.max_p_predict,
        methods=["GET"],
    )

    # 南瑞调控未达标地市结果一键通知
    # GET请求，进行南瑞调控未达标地市结果的一键通知,NotifyPage
    app.add_url_rule(
        "/v1/nanrui/notify",
        view_func=NotifyPage.control_motify,
        methods=["GET"],
    )

